package com.test.deencredit.dialog_deencredit;

import android.annotation.SuppressLint;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;

import com.test.deencredit.R;


public class KindTipDialog_deencredit extends Dialog {

    private final Runnable denyRunnable_deencredit, agreeRunnable_deencredit;

    public KindTipDialog_deencredit(@NonNull Context context, Runnable denyRunnable, Runnable agreeRunnable) {
        super(context);
        this.denyRunnable_deencredit = denyRunnable;
        this.agreeRunnable_deencredit = agreeRunnable;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_kind_tip_deencredit);
        initView_deencredit();
    }

    @SuppressLint("SetTextI18n")
    private void initView_deencredit(){

        getWindow().setBackgroundDrawableResource(R.color.transparent);
        setCanceledOnTouchOutside(false);
        getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

        View denyBtn = findViewById(R.id.dkt_btn_deny);

        if (denyRunnable_deencredit == null) denyBtn.setVisibility(View.GONE);

        denyBtn.setOnClickListener(v -> {
            dismiss();
            if (denyRunnable_deencredit != null) denyRunnable_deencredit.run();
        });

        findViewById(R.id.dkt_btn_agree).setOnClickListener(v -> {
            dismiss();
            if (agreeRunnable_deencredit !=null) agreeRunnable_deencredit.run();
        });

    }

}
